﻿<!DOCTYPE html>
<html>
<head>
	<link href="../resources/presentation.css" rel="stylesheet" type="text/css" />
	<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
	<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

	<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
	<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
<div class="nav"><a href="08_for-tag.html">Prev</a> <a href="index.html">Index</a> <a href="10_if-else-tag.html">Next</a></div>

<h3>JsRender: Composing nested templates: {{for}} with external template</h3>

<script id="movieTmpl" type="text/x-jsrender">
	<tr>
		<td>{{>title}}</td>
		<td>
			{{for languages tmpl="#languageTmpl"/}}
		</td>
	</tr>
</script>

<script id="languageTmpl" type="text/x-jsrender">
	<div>{{>name}}</div>
</script>

<table>
	<thead><tr><th>Title</th><th>Languages</th></tr></thead>
	<tbody id="movieList"></tbody>
</table>

<script type="text/javascript">

var movie = {
	title: "Eyes Wide Shut",
	languages: [
		{ name: "French" },
		{ name: "Mandarin" },
		{ name: "Spanish" }
	]
};

$( "#movieList" ).html(
	$( "#movieTmpl" ).render( movie )
);

</script>

<!--================ End of Demo Section ================-->

<h4>HTML:</h4>
<pre class="brush: xml;">
<!--====== Outer Template ======-->
...
&lt;td>{{>title}}&lt;/td>
&lt;td>
    {{for languages tmpl="#languageTmpl"/}}
&lt;/td>
..

<!--====== Nested Template ======-->
&lt;script id="languageTmpl" type="text/x-jsrender">
    &lt;div>{{>name}}&lt;/div>
&lt;/script>
</pre>

</body>
</html>


